
<template>
  <el-dialog
    title="任务信息详情"
    width="50%"
    :visible.sync="visible"
    
  >
    <el-row v-if="visible">
      <el-form
        label-width="160px"
        disabled
      >
        <el-col :span="12">
          <el-form-item
            label="作业名称"
          >
            <el-input v-model="form.name"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="所属任务分类"
          >
            <TreeSelect v-model="form.pid" :options="treeOption"></TreeSelect>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="调度类型"
          >
            <el-input :value="form.taskScheduleType == 'batch' ? '周期任务': '实时任务'"/>
          </el-form-item>
        </el-col>
        <el-col :span="12" v-if="isBatch">
          <el-form-item
            label="CRON"
          >
            <el-input v-model="form.xxlJobInfo.scheduleConf"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="失败重试次数(次)"
          >
            <el-input v-model="form.xxlJobInfo.executorFailRetryCount"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="超时时间（分钟）"
          >
            <el-input v-model="form.xxlJobInfo.executorTimeout"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="任务状态"
            prop="jobTemplateId"
          >
            <el-tag :type="this.form.state == '1' ? 'success': ''">{{ this.form.state == '1' ? '启动' : '未启动' }}</el-tag>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="任务级别"
            prop="jobTemplateId"
          >
          <el-select v-model="form.level" placeholder="请选择任务级别">
            <el-option
              v-for="item in taskLevel"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="最新修改时间"
            prop="jobTemplateId"
          >
            <el-input v-model="form.updateTime"/>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="描述"
            prop="jobTemplateId"
          > 
            <el-input v-model="form.note" type="textarea"/>
          </el-form-item>
        </el-col>
      </el-form>
      
    </el-row>
    <div style="display: flex; justify-content: flex-end;">
      <el-button type="primary" @click="()=>visible = false">
        关闭
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
import BaseEditForm from '@/views/common/mixins/BaseEditForm'
import { addSchedule } from '@/api/workDevelopment/index'
import { findAllActuator } from '@/api/dispatchTemplate/index'
import CronGenerator from '@/components/CronGenerator/index'
import { queryFn, nextTriggerTime } from '@/api/dispatchTemplate/index'
import { getTree } from '@/api/workDevelopment/index'
import TreeSelect from './treeSelect.vue'

export default {
  components: { TreeSelect },
  mixins: [BaseEditForm],
  props: {
    
  },
  data() {
    return {
      isBatch: false,
      treeOption: [],
      visible: false,
      form: {},
      taskLevel: [
        {label: 'T0', value: 0},
        {label: 'T1', value: 1},
        {label: 'T2', value: 2},
        {label: 'T3', value: 3},
        {label: 'T4', value: 4},
      ]
    }
  },
  watch: {
    // records: {
    //   immediate: true,
    //   handler(val) {
    //   }
    // }
  },
  mounted() {
    
  },
  methods: {
    init(info) {
      this.visible = true;
      this.form = info;
      if(!this.form.xxlJobInfo) {
        this.form.xxlJobInfo = {}
      }
      this.isBatch = info.taskScheduleType == 'batch';
      this.getTreeOptions()
    },
    getTreeOptions() {
      getTree({pid:-1}).then((data) => {
        if (data) {
          let treeTop = [{
            name: '全部',
            id: -1,
            children: data,
            type:1
          }];
          this.treeOption = treeTop;
          console.log('treeOption', this.treeOption);
        }
      })
    },
  }
}
</script>

<style lang="scss" scoped>
/deep/ .el-input.is-disabled .el-input__inner {
  color: black;
}

/deep/ .el-textarea.is-disabled .el-textarea__inner {
  color: black;
}
</style>
